package easy

func DominantIndex(nums []int) int {
	max := 0
	max2 := 0
	index := -1
	for i := 0; i < len(nums); i++ {
		if nums[i] > max {
			max2 = max
			max = nums[i]
			index = i
		} else if nums[i] > max2 {
			max2 = nums[i]
		}
	}
	if max >= max2*2 {
		return index
	}
	return -1
}
